package com.fwtai.api.controller;

import com.fwtai.config.ConfigFile;
import com.fwtai.service.api.CodeService;
import com.fwtai.tool.ToolClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * 获取验证码
*/
@Api(tags = "验证码,token不填",description = "获取验证码")
@RestController
@RequestMapping(ConfigFile.api_v10 + "code")
public class CodeController{

    @Autowired
    private CodeService codeService;

    //获取注册或登录的验证码
    @ApiOperation(value = "获取注册或登录的验证码", notes = "获取验证码,5分钟内有效")
    @GetMapping("/getCode")
    @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号码", dataType = "String", paramType = "query", required = true)})
    public void getCode(final String phone,final HttpServletResponse response){
        ToolClient.responseJson(codeService.getCode(phone),response);
    }
}